package com.junmeng.libfloating.util

import android.view.View
import android.view.ViewGroup

object ViewUtil {
    /**
     * 将child添加到parent中
     */
    fun addView(parent: ViewGroup, child: View) {
        removeViewFromParent(child)
        parent.addView(child)
    }

    /**
     * 从child的父view中移除
     */
    fun removeViewFromParent(child: View) {
        if (child.parent is ViewGroup) {
            (child.parent as ViewGroup).removeView(child)
        }
    }
}